<%--
  Created by IntelliJ IDEA.
  User: YANG
  Date: 2019/11/7
  Time: 21:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
    <title>发布招聘</title>
    <script src="Js/jquery-3.4.1.min.js"></script>
    <script src="Js/jquerysession.js"></script>
    <style type="text/css">
        body{
            background-color: #ECFFF2;
        }
        .center{
            width:500px;
            margin: 0 auto;
        }
        .center input,.center select{
            margin-top: 16px;
            width:180px;
            height:30px;
        }
        input[type="submit"]{
            color: white;
            width: 60px;
            height: 36px;
            background-color:  #6699CC;
            border: 0 solid #6699CC;
        }
        input[type="reset"]{
            color: white;
            width: 60px;
            height: 36px;
            background-color:  #6699CC;
            border: 0 solid #6699CC;
        }
        form{
            color: white;
            background-color: #6699CC;
        }
    </style>
</head>
<body>
<script>
<%--    其他界面切换过来携带了一个参数，但是如何取出来是一个问题，由于是问题--%>
    var jobID=<%=request.getParameter("jobID")%>

        if(jobID!=null){
        //    jobId为空说明用户正常发布招聘，不为空说明修改招聘信息
        $.ajax({
            type:"GET",
            url:"GetReleaseJobByJobID.action?JobID="+jobID,
            dataType:"json",
            success:function (res) {
                $("#JobName").attr("value",res.json.JobName)
                $("#JobAddress").attr("value",res.json.JobAddress)
                $("#JobSalary").attr("value",res.json.JobSalary)
                $("#JobNum").attr("value",res.json.JobNum)
                $("#JobDuty").val(res.json.JobDuty)
                $("#JobRequire").val(res.json.JobRequire)
                //无奈在这里添加一栏，然后提交过去.
                //需要把jobID存起来，当点击保存时，我们就要根据有无jobid来执行更新或是插入操作
                //这边存储的jobID在action端无法识别，需要换一种方式让服务器读懂。
                //关键就是点击表单提交时，怎么顺带把jobID也提交过去呢
                sessionStorage.setItem("jobID",jobID);

            },
            error:function () {

            }
        })
        }else{
            sessionStorage.setItem("jobID","-1");
        }

</script>
<div class="center">
    <form action="ReleaseJob.action" method="post">
        <label>职位名称</label><input id="JobName" name="releasejob.JobName" type="text">
        <label>工作地点</label><input id="JobAddress" name="releasejob.JobAddress" type="text"><br>
        <label>薪资待遇</label><input id="JobSalary" name="releasejob.JobSalary" type="text">
        <label>招聘人数</label><input  id="JobNum" name="releasejob.JobNum" type="text"><br><br>
        <label style="margin-top: 20px;">工作职责</label><textarea id="JobDuty" name="releasejob.JobDuty" style="width: 100%;height: 230px;"></textarea><br><br>
        <label style="margin-top: 20px;">应聘要求</label><textarea id="JobRequire" name="releasejob.JobRequire" style="width: 100%;height: 230px;"></textarea><br>
        <div style="margin-left:200px;">
            <input type="submit" value="发布">
            <input type="reset"  value="重置">
        </div>
    </form>
</div>
</body>


</html>
